package com.mall.xiaomi.mapper;

import com.github.pagehelper.PageInfo;
import com.mall.xiaomi.pojo.Product;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @ClassName ProductMapper
 * @Description TODO
 * @action luoliang
 * @Data 2021/2/24 16:40
 * @Version 1.0
 */
public interface ProductMapper extends Mapper<Product> {
    /**
     * 获取各类商品数据封装
     * @param categoryId
     * @return
     */
    @Select("SELECT * FROM product WHERE category_id=#{categoryId}")
    List<Product> getProductByCategoryId(Integer categoryId);

    /**
     * 获取商品id
     * @return
     */
    @Select("select product_id from product")
    List<Product> getHotProduct();

    /**
     * 商品分类展示
     * @param currentPage
     * @param pageSize
     * @param categoryId
     * @return
     */
    @Select("select * from Product where category_id=#{categoryId} limit currPage=#{currPage},pageSize=#{pageSzie}")
    PageInfo<Product> getProductByPage(@Param("currentPage") String currentPage, @Param("pageSize") String pageSize, @Param("categoryId") String categoryId);

    /**
     * 根据ID搜索商品
     * @param
     */
    @Select("SELECT * FROM product WHERE product_name LIKE CONCAT(CONCAT('%',#{productName},'%'))")
    List<Product> getProduct(String productName);

    
}
